<template>
  <div>
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
      <div class="container-fluid header">
        <h1>学员成绩</h1>
        <p>点击表格修改或录入</p>
      </div>
    </nav>

    <!-- table-striped隔行换色 -->
    <table class="table table-striped">
      <colgroup>
        <col width="14%" />
        <col width="16%" />
        <col width="14%" />
        <col width="14%" />
        <col width="14%" />
        <col width="14%" />
        <col width="14%" />
      </colgroup>
      <thead>
        <tr>
          <th scope="col">学员ID</th>
          <th scope="col">姓名</th>
          <th scope="col">第1次成绩</th>
          <th scope="col">第2次成绩</th>
          <th scope="col">第3次成绩</th>
          <th scope="col">第4次成绩</th>
          <th scope="col">第5次成绩</th>
        </tr>
      </thead>
      <tbody v-for="(item, index) in ScoreInfo" :key="index" ref="tbody">
        <tr>
          <th scope="row">{{ item.group }}</th>
          <td>{{ item.name }}</td>
          <td class="score">{{ item.score[0] }}</td>
          <td class="score">{{ item.score[1] }}</td>
          <td class="score">{{ item.score[2] }}</td>
          <td class="score">{{ item.score[3] }}</td>
          <td class="score">{{ item.score[4] }}</td>
        </tr>
      </tbody>
    </table>
    <!-- <button @click="btn">点击</button> -->
  </div>
</template>

<script>
import "bootstrap/dist/css/bootstrap.min.css";
// 导入成绩信息接口
import { getScoreInfo } from "../api/score";

export default {
  data() {
    return {
      //1
      ScoreInfo: {},
    };
  },
  // 在created生命周期渲染页面
  async created() {
    // console.log('a',);
    const res = await getScoreInfo();
    // console.log('res', res);
    // res.data.data为列表数据 把数据渲染到页面即可
    this.ScoreInfo = res.data.data;

    // let html = "";
    // for (const key in res.data.data) {
    //   const { name, score } = res.data.data[key];

    //   html += `
    //     <tr>
    //       <th scope="row">${key}</th>
    //       <td>${name}</td>
    //       <td class="score">${score[0]}</td>
    //       <td class="score">${score[1]}</td>
    //       <td class="score">${score[2]}</td>
    //       <td class="score">${score[3]}</td>
    //       <td class="score">${score[4]}</td>
    //     </tr>
    //     `;
    // }
    // this.$refs.tbody.innerHTML = html;
  },
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}

body {
  background-color: #f1f1f1;
  color: #6d767e;
  padding: 15px;
  box-sizing: border-box;
  font-size: 14px;
}

.header {
  height: 36px !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 18px;
  margin-bottom: 0 !important;
}

/* 表格 */
.table {
  margin: 10px auto;
  width: 100%;
  border-left: solid 1px #ccc;
  border-top: solid 1px #ccc;
  border-spacing: 0;
  border-radius: 4px;
  background-color: #fff;
  font-size: 12px;
}

.table th,
.table td {
  border-right: solid 1px #ccc;
  border-bottom: solid 1px #ccc;
  padding: 8px 0;
  text-align: center;
}

.table tr th:last-child {
  border-radius: 0 4px 0 0;
}

.table tbody tr:last-child td:first-child {
  border-radius: 0 0 0 4px;
}

.table tbody tr:last-child td:last-child {
  border-radius: 0 0 4px 0;
}

.table tr {
  line-height: 32px;
}

/* .btn-primary {
  background-color: #747ced !important;
  border-color: #747ced !important;
} */
.table .btn-sm {
  zoom: 0.8 !important;
}

.float {
  float: right;
  margin-bottom: 10px;
}

.flex {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

@media (min-width: 576px) {
  .modal-dialog {
    width: 385px !important;
  }
}

.flex {
  display: flex;
}

.col-auto {
  height: 30px !important;
  margin-top: 0 !important;
}

.col-form-label {
  font-size: 14px !important;
}

tbody td {
  position: relative;
}

tbody input {
  /* display: none; */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  background-color: rgb(255, 255, 94);
  outline-color: skyblue;
  text-align: center;
}
</style>